home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Toolbox / Visual Basic Toolbox (P.I.E.)(1996).ISO / version / ver10 / sa_setup.frm < prev    next >
Text File  |  1994-04-30  |  14KB  |  552 lines

  1. VERSION 2.00
  2. Begin Form Form1 
  3.    BorderStyle     =   3  'Fixed Double
  4.    Caption         =   "Setup Apprentice"
  5.    ClientHeight    =   5490
  6.    ClientLeft      =   1035
  7.    ClientTop       =   2070
  8.    ClientWidth     =   6390
  9.    Height          =   6180
  10.    Icon            =   SA_SETUP.FRX:0000
  11.    Left            =   975
  12.    LinkTopic       =   "Form1"
  13.    MaxButton       =   0   'False
  14.    MinButton       =   0   'False
  15.    ScaleHeight     =   5490
  16.    ScaleWidth      =   6390
  17.    Top             =   1440
  18.    Width           =   6510
  19.    Begin CommonDialog CMDialog1 
  20.       Left            =   5640
  21.       Top             =   5040
  22.    End
  23.    Begin TextBox AppName 
  24.       Height          =   285
  25.       Left            =   2280
  26.       TabIndex        =   3
  27.       Top             =   480
  28.       Width           =   3855
  29.    End
  30.    Begin PictureBox Drop 
  31.       BorderStyle     =   0  'None
  32.       Height          =   495
  33.       Left            =   4080
  34.       Picture         =   SA_SETUP.FRX:0302
  35.       ScaleHeight     =   495
  36.       ScaleWidth      =   495
  37.       TabIndex        =   8
  38.       Top             =   5040
  39.       Visible         =   0   'False
  40.       Width           =   495
  41.    End
  42.    Begin PictureBox NoDrop 
  43.       BorderStyle     =   0  'None
  44.       Height          =   495
  45.       Left            =   3480
  46.       Picture         =   SA_SETUP.FRX:0604
  47.       ScaleHeight     =   495
  48.       ScaleWidth      =   495
  49.       TabIndex        =   7
  50.       Top             =   5040
  51.       Visible         =   0   'False
  52.       Width           =   495
  53.    End
  54.    Begin Timer Timer1 
  55.       Interval        =   100
  56.       Left            =   5160
  57.       Top             =   5040
  58.    End
  59.    Begin DirListBox Dir1 
  60.       Height          =   1380
  61.       Left            =   240
  62.       TabIndex        =   1
  63.       Top             =   1200
  64.       Width           =   1815
  65.    End
  66.    Begin DriveListBox Drive1 
  67.       Height          =   315
  68.       Left            =   240
  69.       TabIndex        =   0
  70.       Top             =   480
  71.       Width           =   1815
  72.    End
  73.    Begin FileListBox File1 
  74.       DragIcon        =   SA_SETUP.FRX:0906
  75.       Height          =   2175
  76.       Left            =   240
  77.       MultiSelect     =   2  'Extended
  78.       TabIndex        =   2
  79.       Top             =   3000
  80.       Width           =   1815
  81.    End
  82.    Begin ListBox IList 
  83.       DragIcon        =   SA_SETUP.FRX:0C08
  84.       Height          =   1005
  85.       Index           =   2
  86.       Left            =   2280
  87.       MultiSelect     =   2  'Extended
  88.       Sorted          =   -1  'True
  89.       TabIndex        =   6
  90.       Top             =   4080
  91.       Width           =   3855
  92.    End
  93.    Begin ListBox IList 
  94.       DragIcon        =   SA_SETUP.FRX:0F0A
  95.       Height          =   1005
  96.       Index           =   1
  97.       Left            =   2280
  98.       MultiSelect     =   2  'Extended
  99.       Sorted          =   -1  'True
  100.       TabIndex        =   5
  101.       Top             =   2760
  102.       Width           =   3855
  103.    End
  104.    Begin ListBox IList 
  105.       DragIcon        =   SA_SETUP.FRX:120C
  106.       Height          =   1395
  107.       Index           =   0
  108.       Left            =   2280
  109.       MultiSelect     =   2  'Extended
  110.       Sorted          =   -1  'True
  111.       TabIndex        =   4
  112.       Top             =   1080
  113.       Width           =   3855
  114.    End
  115.    Begin Label Label7 
  116.       Caption         =   "Application Name:"
  117.       Height          =   255
  118.       Left            =   2280
  119.       TabIndex        =   15
  120.       Top             =   240
  121.       Width           =   2295
  122.    End
  123.    Begin Label Label6 
  124.       Caption         =   "Files:"
  125.       Height          =   255
  126.       Left            =   240
  127.       TabIndex        =   14
  128.       Top             =   2760
  129.       Width           =   1215
  130.    End
  131.    Begin Label Label5 
  132.       Caption         =   "Directory:"
  133.       Height          =   255
  134.       Left            =   240
  135.       TabIndex        =   13
  136.       Top             =   960
  137.       Width           =   1215
  138.    End
  139.    Begin Label Label4 
  140.       Caption         =   "Drive:"
  141.       Height          =   255
  142.       Left            =   240
  143.       TabIndex        =   12
  144.       Top             =   240
  145.       Width           =   1215
  146.    End
  147.    Begin Label Label3 
  148.       Caption         =   "System Directory:"
  149.       Height          =   255
  150.       Left            =   2280
  151.       TabIndex        =   11
  152.       Top             =   3840
  153.       Width           =   2295
  154.    End
  155.    Begin Label Label2 
  156.       Caption         =   "Windows Directory:"
  157.       Height          =   255
  158.       Left            =   2280
  159.       TabIndex        =   10
  160.       Top             =   2520
  161.       Width           =   2295
  162.    End
  163.    Begin Label Label1 
  164.       Caption         =   "Application Directory:"
  165.       Height          =   255
  166.       Left            =   2280
  167.       TabIndex        =   9
  168.       Top             =   840
  169.       Width           =   2295
  170.    End
  171.    Begin Menu MenuFile 
  172.       Caption         =   "&File"
  173.       Begin Menu MenuFileOpen 
  174.          Caption         =   "&Open"
  175.       End
  176.       Begin Menu MenuFileClose 
  177.          Caption         =   "&Close"
  178.       End
  179.       Begin Menu MenuFileSave 
  180.          Caption         =   "&Save"
  181.       End
  182.       Begin Menu MenuFileSaveAs 
  183.          Caption         =   "Save &As"
  184.       End
  185.       Begin Menu sep1 
  186.          Caption         =   "-"
  187.       End
  188.       Begin Menu MenuFileExit 
  189.          Caption         =   "E&xit"
  190.       End
  191.    End
  192.    Begin Menu MenuCreateDisk 
  193.       Caption         =   "Create Disk!"
  194.       Enabled         =   0   'False
  195.    End
  196.    Begin Menu MenuHelp 
  197.       Caption         =   "&Help"
  198.       Begin Menu MenuHelpAbout 
  199.          Caption         =   "&About Setup Apprentice ..."
  200.       End
  201.    End
  202. End
  203. Option Explicit
  204.  
  205. Dim SetupFilename As String
  206.  
  207. Dim fChanged As Integer
  208. Dim StartDrag As Integer
  209. Dim DragStart As Integer
  210. Dim DragCount As Integer
  211.  
  212. Sub AppName_Change ()
  213.     SetFormCaption
  214.  
  215.     MenuCreateDisk.Enabled = Len(AppName.Text)
  216. End Sub
  217.  
  218. Function CheckSave () As Integer
  219.     If fChanged Then
  220.     End If
  221.  
  222.     CheckSave = True
  223. End Function
  224.  
  225. Sub Dir1_Change ()
  226.     File1.Path = Dir1.Path
  227. End Sub
  228.  
  229. Sub Dir1_DragOver (Source As Control, X As Single, Y As Single, State As Integer)
  230.     DragOver Source, State
  231. End Sub
  232.  
  233. Sub Drive1_Change ()
  234.     Dir1.Path = Drive1.Drive
  235. End Sub
  236.  
  237. Sub Drive1_DragOver (Source As Control, X As Single, Y As Single, State As Integer)
  238.     DragOver Source, State
  239. End Sub
  240.  
  241. Sub File1_MouseDown (Button As Integer, Shift As Integer, X As Single, Y As Single)
  242.     If (Button = 1) And File1.ListIndex <> -1 Then
  243.         StartDrag = True
  244.         DragStart = -1
  245.         Timer1.Enabled = True
  246.     End If
  247. End Sub
  248.  
  249. Sub File1_MouseUp (Button As Integer, Shift As Integer, X As Single, Y As Single)
  250.     If (Button = 1) Then StartDrag = False: File1.Drag 0
  251. End Sub
  252.  
  253. Sub Form_DragOver (Source As Control, X As Single, Y As Single, State As Integer)
  254.     DragOver Source, State
  255. End Sub
  256.  
  257. Sub Form_Load ()
  258.     SetupClear
  259.     SetFormCaption
  260. End Sub
  261.  
  262. Sub Form_Unload (Cancel As Integer)
  263.     If CheckSave() Then End
  264. End Sub
  265.  
  266. Sub IList_DragDrop (Index As Integer, Source As Control, X As Single, Y As Single)
  267.     Dim fAdd As Integer
  268.     Dim I As Integer
  269.     Dim J As Integer
  270.     Dim N As Integer
  271.     Dim S As String
  272.     Dim DirPath As String
  273.  
  274.     fChanged = True
  275.  
  276.     If (DragStart <> Index) Then
  277.         If (DragStart = -1) Then
  278.             N = File1.ListCount
  279.  
  280.             If Right$(Dir1.Path, 1) = "\" Then
  281.                 DirPath = Dir1.Path
  282.             Else
  283.                 DirPath = Dir1.Path & "\"
  284.             End If
  285.         Else
  286.             N = IList(DragStart).ListCount
  287.         End If
  288.  
  289.         For I = N - 1 To 0 Step -1
  290.             S = ""
  291.  
  292.             If (DragStart = -1) Then
  293.                 If File1.Selected(I) Then S = DirPath & File1.List(I)
  294.             ElseIf IList(DragStart).Selected(I) Then
  295.                 S = IList(DragStart).List(I)
  296.                 IList(DragStart).RemoveItem I
  297.             End If
  298.  
  299.             If Len(S) Then
  300.                 fAdd = True
  301.  
  302.                 For J = 0 To IList(Index).ListCount - 1
  303.                     If S = IList(Index).List(J) Then
  304.                         fAdd = False
  305.                         Exit For
  306.                     End If
  307.                 Next J
  308.  
  309.                 If fAdd Then IList(Index).AddItem S
  310.             End If
  311.         Next I
  312.     End If
  313. End Sub
  314.  
  315. Sub IList_MouseDown (Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
  316.     Dim I As Integer
  317.  
  318.  
  319.     If (Button = 1) And IList(Index).ListIndex <> -1 Then
  320.         StartDrag = True
  321.         DragStart = Index
  322.         Timer1.Enabled = True
  323.     End If
  324.  
  325.     If (Button = 2) Then
  326.         MsgBox Format$(Y)
  327.     End If
  328. End Sub
  329.  
  330. Sub IList_MouseUp (Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
  331.     If Button = 1 Then StartDrag = False: IList(Index).Drag 0
  332. End Sub
  333.  
  334. Sub Label1_DragOver (Source As Control, X As Single, Y As Single, State As Integer)
  335.     DragOver Source, State
  336. End Sub
  337.  
  338. Sub Label2_DragOver (Source As Control, X As Single, Y As Single, State As Integer)
  339.     DragOver Source, State
  340. End Sub
  341.  
  342. Sub Label3_DragOver (Source As Control, X As Single, Y As Single, State As Integer)
  343.     DragOver Source, State
  344. End Sub
  345.  
  346. Sub Label4_DragOver (Source As Control, X As Single, Y As Single, State As Integer)
  347.     DragOver Source, State
  348. End Sub
  349.  
  350. Sub Label5_DragOver (Source As Control, X As Single, Y As Single, State As Integer)
  351.     DragOver Source, State
  352. End Sub
  353.  
  354. Sub Label6_DragOver (Source As Control, X As Single, Y As Single, State As Integer)
  355.     DragOver Source, State
  356. End Sub
  357.  
  358. Sub MenuCreateDisk_Click ()
  359.     Form1.Hide
  360.     Form3.Show 1
  361.     Form1.Show
  362. End Sub
  363.  
  364. Sub MenuFileClose_Click ()
  365.     If CheckSave() Then SetupClear
  366. End Sub
  367.  
  368. Sub MenuFileExit_Click ()
  369.     If CheckSave() Then End
  370. End Sub
  371.  
  372. Sub MenuFileOpen_Click ()
  373.     On Error GoTo NoOpen
  374.     CMDialog1.Filename = "*.SA"
  375.     CMDialog1.Flags = &H9804
  376.     CMDialog1.Filter = "Setup Assitant (*.SA)|*.SA|All Files (*.*)|*.*"
  377.     CMDialog1.CancelError = True
  378.     CMDialog1.Action = 1
  379.  
  380.     OpenSetup CMDialog1.Filename
  381.  
  382.     SetupFilename = CMDialog1.Filename
  383.     Call SetFormCaption
  384.  
  385.     GoTo OpenDone
  386.  
  387. NoOpen:
  388.     Resume OpenDone
  389.  
  390. OpenDone:
  391.     On Error GoTo 0
  392. End Sub
  393.  
  394. Sub MenuFileSave_Click ()
  395.     If AppName.Text = "" Then
  396.         Beep
  397.         MsgBox "You need to fill in the Application Name.", 48, "Save File"
  398.     ElseIf SetupFilename = "" Then
  399.         Call MenuFileSaveAs_Click
  400.     Else
  401.         SaveSetup SetupFilename
  402.     End If
  403. End Sub
  404.  
  405. Sub MenuFileSaveAs_Click ()
  406.     Dim I As Integer
  407.     Dim S As String
  408.     Dim C As String
  409.  
  410.     If AppName.Text = "" Then
  411.         Beep
  412.         MsgBox "You need to fill in the Application Name.", 48, "Save File"
  413.         Exit Sub
  414.     End If
  415.  
  416.     On Error GoTo NoSave
  417.  
  418.     If SetupFilename <> "" Then
  419.         CMDialog1.Filename = "*.SA"
  420.     Else
  421.         S = ""
  422.  
  423.         For I = 1 To Len(AppName.Text)
  424.             C = Mid$(UCase$(AppName.Text), I, 1)
  425.             If ((C >= "A") And (C <= "Z")) Then S = S & Mid$(AppName.Text, I, 1)
  426.         Next I
  427.  
  428.         CMDialog1.Filename = Left$(S, 8) & ".SA"
  429.     End If
  430.  
  431.     CMDialog1.Flags = &H9804
  432.     CMDialog1.Filter = "Setup Assitant (*.SA)|*.SA|All Files (*.*)|*.*"
  433.     CMDialog1.CancelError = True
  434.     CMDialog1.Action = 2
  435.  
  436.     SetupFilename = CMDialog1.Filename
  437.     Call SetFormCaption
  438.  
  439.     SaveSetup CMDialog1.Filename
  440.     GoTo SaveDone
  441.  
  442. NoSave:
  443.     Resume SaveDone
  444.  
  445. SaveDone:
  446.     On Error GoTo 0
  447. End Sub
  448.  
  449. Sub MenuHelpAbout_Click ()
  450.     Form2.Show 1
  451. End Sub
  452.  
  453. Sub OpenSetup (ByVal Filename As String)
  454.     Dim S As String
  455.  
  456.     SetupClear
  457.  
  458.     SetupFilename = Filename
  459.     MenuCreateDisk.Enabled = False
  460.  
  461.     Open Filename For Input Access Read As #1
  462.  
  463.     While Not EOF(1)
  464.         Input #1, S
  465.  
  466.         If Left$(S, 8) = "AppName" Then
  467.             AppName.Text = Mid$(S, 9)
  468.             MenuCreateDisk.Enabled = Len(AppName.Text)
  469.         ElseIf Left$(S, 7) = "WinDir " Then
  470.             IList(1).AddItem Mid$(S, 8)
  471.         ElseIf Left$(S, 7) = "SysDir " Then
  472.             IList(2).AddItem Mid$(S, 8)
  473.         ElseIf Left$(S, 7) = "AppDir " Then
  474.             IList(0).AddItem Mid$(S, 8)
  475.         ElseIf Left$(S, 6) = "Drive " Then
  476.             Drive1.Drive = Mid$(S, 7)
  477.         ElseIf Left$(S, 4) = "Dir " Then
  478.             Dir1.Path = Mid$(S, 5)
  479.             File1.Path = Mid$(S, 5)
  480.         End If
  481.     Wend
  482.  
  483.     Close #1
  484. End Sub
  485.  
  486. Sub SetFormCaption ()
  487.     Dim S As String
  488.  
  489.  
  490.     S = "Setup Apprentice - "
  491.  
  492.     If Len(AppName.Text) Then
  493.         S = S & AppName.Text
  494.     Else
  495.         S = S & "New Application"
  496.     End If
  497.  
  498.     If Len(SetupFilename) Then
  499.         S = S & " [" & SetupFilename & "]"
  500.     Else
  501.         S = S & " [UNKNOWN.SA]"
  502.     End If
  503.  
  504.     Form1.Caption = S
  505. End Sub
  506.  
  507. Sub SetupClear ()
  508.     fChanged = False
  509.     AppName.Text = ""
  510.     SetupFilename = ""
  511.     IList(0).Clear
  512.     IList(1).Clear
  513.     IList(2).Clear
  514. End Sub
  515.  
  516. Sub Timer1_Timer ()
  517.     Dim I As Integer
  518.     Dim N As Integer
  519.  
  520.     If StartDrag Then
  521.         Timer1.Enabled = False
  522.         N = 0
  523.  
  524.         Select Case DragStart
  525.             Case -1:
  526.                 For I = 0 To File1.ListCount - 1
  527.                     If File1.Selected(I) Then N = N + 1
  528.                 Next I
  529.  
  530.             Case Else:
  531.                 For I = 0 To IList(DragStart).ListCount - 1
  532.                     If IList(DragStart).Selected(I) Then N = N + 1
  533.                 Next I
  534.         End Select
  535.  
  536.         If N Then
  537.             Select Case DragStart
  538.                 Case -1:
  539.                     File1.DragIcon = Drop.Picture
  540.                     File1.Drag 1
  541.     
  542.                 Case Else:
  543.                     IList(DragStart).DragIcon = Drop.Picture
  544.                     IList(DragStart).Drag 1
  545.             End Select
  546.         End If
  547.  
  548.         StartDrag = False
  549.     End If
  550. End Sub
  551.  
  552.